// Create a Promise which can be resolve manually
export type PendingPromise<T> = Promise<T> & { resolve: (T?: any) => void; reject: (e: Error) => void };
export const pendingResolve = <T>() => {
  const container = {} as any;
  container.p = new Promise((r, j) => ([container.r, container.j] = [r, j]));
  [container.p.resolve, container.p.reject] = [container.r, container.j];
  return container.p as PendingPromise<T>;
};
